package com.laicunba.service;

import java.math.BigDecimal;
import java.util.List;

import com.laicunba.pojo.CurrentAccountItemDO;
import com.laicunba.pojo.vo.CurrentAccountProfitVO;
import com.laicunba.service.CurrentAccountService.RedemptionParam;
import com.laicunba.service.CurrentAccountService.RedemptionResult;
import com.laicunba.service.CurrentAccountService.T0RedemptionBalance;

public interface CurrentAccountService extends BaseService {
	/**
	 * 每日收益
	 */
	public static final String MARK_PROFIT = "PROFIT";

	class WithdrawApplyParam {
		private String userId;
		private BigDecimal withdrawAmount;
		private String bankCode;// 银行代码
		private String bankName; // 银行名字
		private String bankCardNo; // 银行卡
		private String holder; // 持卡人
		private String pid; // 身份证
		private String mark = "";

		public String getUserId() {
			return userId;
		}

		public BigDecimal getWithdrawAmount() {
			return withdrawAmount;
		}

		public String getBankCode() {
			return bankCode;
		}

		public String getBankName() {
			return bankName;
		}

		public String getBankCardNo() {
			return bankCardNo;
		}

		public String getHolder() {
			return holder;
		}

		public String getPid() {
			return pid;
		}

		public String getMark() {
			return mark;
		}

		public void setUserId(String userId) {
			this.userId = userId;
		}

		public void setWithdrawAmount(BigDecimal withdrawAmount) {
			this.withdrawAmount = withdrawAmount;
		}

		public void setBankCode(String bankCode) {
			this.bankCode = bankCode;
		}

		public void setBankName(String bankName) {
			this.bankName = bankName;
		}

		public void setBankCardNo(String bankCardNo) {
			this.bankCardNo = bankCardNo;
		}

		public void setHolder(String holder) {
			this.holder = holder;
		}

		public void setPid(String pid) {
			this.pid = pid;
		}

		public void setMark(String mark) {
			this.mark = mark;
		}

	}

	boolean createAccount(String uid);

	/**
	 * 增加
	 * 
	 * @param uid
	 * @param amount
	 *            > 0
	 * @param mark
	 * @param summary
	 * @return
	 */
	CurrentAccountItemDO add(String uid, BigDecimal amount, String mark, String summary);

	/**
	 * 减少金额
	 * 
	 * @param uid
	 * @param amount
	 * @param mark
	 * @param summary
	 * @return
	 */
	CurrentAccountItemDO subtract(String uid, BigDecimal amount, String mark, String summary);

	/**
	 * 计算一天的利息
	 * 
	 * @param balance
	 * @param rate
	 * @return
	 */
	BigDecimal countOneDayProfit(BigDecimal balance, BigDecimal rate);

	/**
	 * 计算并增加今天的收益
	 * 
	 * @param uid
	 * @param rate
	 * @return
	 */
	boolean incrDailyProfit(String uid, BigDecimal rate);

	BigDecimal getBalance(String uid);

	/**
	 * 取现申请
	 * 
	 * @param parm
	 * @return withdrawId
	 */
	String withdrawApply(WithdrawApplyParam parm);

	CurrentAccountProfitVO getProfit(String uid);

	List<String> findNoProfitLockerAccounts(int limit);

	boolean clearProfitLocker();

	class RedemptionParam {
		private BigDecimal amt;
		private String uid;

		public BigDecimal getAmt() {
			return amt;
		}

		public void setAmt(BigDecimal amt) {
			this.amt = amt;
		}

		public String getUid() {
			return uid;
		}

		public void setUid(String uid) {
			this.uid = uid;
		}

	}

	class RedemptionResult {
		private BigDecimal balance;
		private String withdrawId;
		public void setWithdrawId(String withdrawId) {
			this.withdrawId = withdrawId;
		}
		public String getWithdrawId() {
			return withdrawId;
		}
		public void setBalance(BigDecimal balance) {
			this.balance = balance;
		}

		public BigDecimal getBalance() {
			return balance;
		}
	}

	/**
	 * 赎回
	 * 
	 * @param param
	 * @return
	 */
	RedemptionResult redemption(RedemptionParam param);

	RedemptionResult redemptionApply(RedemptionParam param);

	boolean redemptionTransfer(String withdrawId);
	
	public class T0RedemptionBalance{
		private BigDecimal  dailyLimitAmt;
		private BigDecimal  usedAmt;
		private BigDecimal  balance;
		public BigDecimal getDailyLimitAmt() {
			return dailyLimitAmt;
		}
		public void setDailyLimitAmt(BigDecimal dailyLimitAmt) {
			this.dailyLimitAmt = dailyLimitAmt;
		}
		public BigDecimal getUsedAmt() {
			return usedAmt;
		}
		public void setUsedAmt(BigDecimal usedAmt) {
			this.usedAmt = usedAmt;
		}
		public BigDecimal getBalance() {
			return balance;
		}
		public void setBalance(BigDecimal balance) {
			this.balance = balance;
		} 
		
	}

	T0RedemptionBalance getT0RedemptionBalance();

	T0RedemptionBalance updateT0RedemptionLimitAmt(BigDecimal amt, boolean persistence);

	BigDecimal subtractT0Balance(BigDecimal amt);
}
